<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/6
 * Time: 10:24
 */
header('Content-Type:application/json');
include '../classes/conn.php';
include '../classes/logincheck.php';
if(islogin()=="teacher_login") {
    $query = "select num,name from class where teacher='{$_SESSION['t_num']}'";
    $result = mysql_query($query);
    $classes = array();
    while ($row = mysql_fetch_assoc($result)) {
        $classes[] = $row;
    }
    $sums=array();
    for($i=0;$i<count($classes);$i++){
        $query="select count(*) from student where class='{$classes[$i]['num']}'";
        $res=mysql_query($query);
        $row=mysql_fetch_assoc($res);
        $classes[$i]['sum'][]=$row['count(*)'];
    }

    $data = urlencode(json_encode($classes));
    $data = urldecode($data);
    echo $data;
    mysql_close($conn);
}